#include "stdafx.h"
#include "CharacterTypeInfo.h"

using namespace System;
using namespace System::Data;
using namespace System::Xml;
using namespace System::Windows::Forms;
using namespace System::Collections::Generic;

CharacterTypeInfo::CharacterTypeInfo()
{
	Initialize();
}

CharacterTypeInfo::~CharacterTypeInfo()
{
}

void CharacterTypeInfo::Initialize()
{
	try
	{
		m_CharacterTypeXml = gcnew XmlDocument();
		m_CharacterTypeXml->Load("xml/CharacterType.xml");
		m_CharacterGenericXml = gcnew XmlDocument();
	}
	catch (Exception^)
	{
		MessageBox::Show("Error opening CharacterType.xml");
	}
}

XmlNodeList^ CharacterTypeInfo::GetTypes()
{
	return (m_CharacterTypeXml->GetElementsByTagName("Type"));
}

XmlNodeList^ CharacterTypeInfo::GetTemplates(System::Xml::XmlNode ^pcType)
{
	String^ strGenericPath = pcType->Attributes->GetNamedItem("File")->Value;

	m_CharacterGenericXml->Load(strGenericPath);
	return (m_CharacterGenericXml->GetElementsByTagName("Template"));
}

CharacterTypeInfo^ CharacterTypeInfo::GetInstance()
{
	if (m_Instance == nullptr)
	{
		m_Instance = gcnew CharacterTypeInfo();
	}
	return (m_Instance);
}